import { createApp, toRefs } from 'vue'
import { createPinia } from 'pinia'
import router from './router'
import App from './App.vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import { userMenuListStore } from '@/store/index'
import { regAllDirective } from './directive/index'

const app = createApp(App)
app.use(router)
app.use(ElementPlus)
app.use(createPinia())
regAllDirective(app)

// const AppStore = userMenuListStore()
// const { btnList } = toRefs(AppStore)
// // app.provide('AppStore', AppStore)
// console.log(AppStore.btnList)
// app.directive('permission', {
//   mounted(el, binding) {
//     // binding传进来的值
//     const permissions = Array.isArray(binding.value) ? binding.value : [binding.value]
//     const hasPermission = permissions.some((permission) => AppStore.btnList.includes(permission))
//     console.log(hasPermission, '我是全局指令')

//     if (!hasPermission) {
//       el.style.display = 'none'
//       el.parentNode?.removeChild(el)
//     }
//   },
// })

app.mount('#app')
